<?php
/**
 * Created by PhpStorm.
 * User: skytop
 * Date: 2016/7/17
 * Time: 13:15
 */

namespace Home\Controller;


use Think\Controller;

class BoardController extends Controller
{
    public function index(){
        /*U('Board/s',array('uid'=>1),'',1);die;*/
        $wishTable=M('wish');
        $view=$wishTable->select();
        $this->assign('view',$view);
        $this->display();
    }

    public function handle(){
        if(!IS_AJAX) {
            E('页面不存在', 404);
        }else {
            $data = array(
                'username' => I('post.username'),
                'content' => I('post.content'),
                'time' => time()
            );
            $wishTable = D('Board');
            if ($id=$wishTable->addMsg($data['username'], $data['content'], $data['time'])) {
                //用jq显示输出
                $send=array(
                    'username'=>$data['username'],
                    'content'=>phiz($data['content']),
                    'time'=>date('Y-m-d H:i',$data['time']),
                    'id'=>$id
                );
                $this->ajaxReturn($send,'json');
            } else {
                $this->ajaxReturn($wishTable->getError());
            }
            /*echo json_encode('sss');exit;*/

        }
    }

    public function face(){
        $content="你好吗[抱抱]不知道怎么样[偷笑]";
        dump(phiz($content));
    }
}